
package jtrimet.android.widget;

import java.text.SimpleDateFormat;

import jtrimet.*;
import android.content.Context;
import android.widget.*;

public class ArrivalView extends LinearLayout
{
	public ArrivalView(Context context, Arrival a)
	{
		super(context);
	
		this.setOrientation(LinearLayout.VERTICAL);
		
		TextView arrival = new TextView(context);
		
		String time = "";

		if (a.isArrivingWithin(Arrival.SIXTY_MINUTES))
		{
			time = a.getWaitTimeInMinutes().toString() + " minutes"; 
		}
		else
		{
			if (a.getStopTime() == null)
			{
				time = "";
			}
			else
			{
				SimpleDateFormat fmt = new SimpleDateFormat("h:mm a");
				time = fmt.format(a.getStopTime().getTime());
			}
		}
		
		arrival.setText(a.getShortsign() + " " + time);
		this.addView(arrival);
					
	}

}
